home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc Development Framework / Documentation / Development Notes / 'nmap', Icon, & Part Signature next >
Encoding:
Text File  |  1996-04-26  |  10.2 KB  |  253 lines  |  [TEXT/ttxt]

  1. OpenDoc
  2. Development
  3. Framework
  4.                                                                                                                                                                                     
  5. 'nmap', Icon, & Part Signature 
  6. ODF Release 1                                                                                                                                                             
  7.  
  8.  
  9. Table of Contents
  10. -------------------------
  11. • Why You Need to Change Your Part's Resources
  12. • Modifying Your 'nmap' Resources
  13. • Changing Your Part Signature
  14. • Changing Your Part Icons
  15.  
  16.  
  17. Why You Need to Change Your 'nmap' Resources
  18.  
  19. Whenever you create a part editor, you must supply OpenDoc with a series of 'nmap' resources, which provide OpenDoc with a multitude of information about your part. When you create a new part using PartMaker, you get a set of 'nmap' resources, which correspond to the kinds of data supported by the part that was used to generate the PartMaker template. You need to change these resources to reflect the information contained in your part.
  20.  
  21. In addition to the 'nmap' resources, OpenDoc on the Mac OS requires you to specify a unique OSType that corresponds to your part's creator signature. You will also want to add unique icons for your part so that users can distinguish between your part and others. Changing these two things is a matter of manipulating your 'BNDL' resources and setting the appropriate creator type in your development environment. 
  22.  
  23. You need to replace the creator, file type and stationery type in three files. 
  24.  
  25. 1) In the file Binding.k, change this line:
  26. #define MyContainerOSType 'DFPJ'    ==> 'WXYZ'  (Your File Type)
  27.  
  28. 2) In the file MacMake.bmk, change this line:
  29. __ComponentSignature = 'ODFJ' ==> 'ABCD'  (Your Creator)
  30.  
  31. 3) In the file "Part.r", change four resources:
  32. resource 'FREF' (129) {
  33.     'DFPJ',  ==> 'WXYZ'    (Your File Type)
  34. resource 'FREF' (130) {
  35.     'sFPJ',  ==> 'sXYZ'    (Your Stationery File Type (File Type with 's' as first letter))
  36. resource 'BNDL' (128) {
  37.     'ODFJ',  ==> 'ABCD'  (Your Creator)
  38. data 'ODFJ' (0, "Owner resource")  ==> 'ABCD'  (Your Creator)
  39.  
  40. We encourage you to change these identifiers before building your part for the first time. 
  41.  
  42. So the basic checklist of resources to modify is as follows:
  43.  
  44.    - 'nmap' resources
  45.    - Mac OS creator type for the part
  46.    - Mac OS icons for the part
  47.  
  48.  
  49. Modifying Your 'nmap' Resources
  50.  
  51. Your part can have several 'nmap' resources, depending on the types of data your part supports and the structure of your part editor. The most commonly used 'nmap' resources are as follows: 
  52.  
  53.    - Kind->Category mapping
  54.    - Editor->Kind mapping
  55.    - Editor User String
  56.    - Kind User String
  57.    - Category User String (only if you do not use an OpenDoc defined category)
  58.    - Mac OS Type mapping
  59.  
  60. In addition, you may want to supply one other type of 'nmap' resource to map platform-types to your part editor, for use during data interchange operations. This Platform Type mapping is described later in this section. 
  61.  
  62. Note: the following examples assume the creation of a sample part called YourPart, which is being developed from a basic PartMaker template. This part supports a custom data format and also supports the data format of another part called SurfPart. This part can also import 'TEXT' and 'PICT' data from standard Mac OS applications.
  63.  
  64. The OpenDoc Developer Release CDs also have documentation that describes how to create 'nmap' resources for your part. See these documents for more information about 'nmap' resources.
  65.  
  66. Kind->Category mapping
  67. The Kind->Category mapping allows OpenDoc to map the data format(s) defined by your part to a more generic category, such as Text or Graphics. The basic format of this resource looks like the following:
  68.  
  69. resource kODNameMappings (kKindCategoryMapId)
  70. {
  71.     kODKind,
  72.     {
  73.         kYourPartKind, 
  74.         kODIsAnISOStringList 
  75.         {
  76.             {
  77.                 kODCategoryDrawing,
  78.                 kYourNewCategory
  79.             }
  80.         }
  81.     }
  82. }
  83.  
  84. In this example, the kYourPartKind string is an ISO string describing the data format supported by your part. The constant kODCategoryDrawing is defined by OpenDoc as the generic category for object-oriented graphics formats. The kYourNewCategory is a custom category that also describes the part's data. You do not have to support multiple categories in your part, only the ones that make sense for your data.
  85.  
  86. You must change the text of the kYourPartKind string to match the data format your part supports. You must also change category string(s) to match the category(s) that your part's data falls into.
  87.  
  88. Editor->Kind mapping
  89. The Editor->Kind mapping allows OpenDoc to map your part editor to the data format(s) it supports in its storage unit. The basic format of this resource looks like the following:
  90.  
  91. resource kODNameMappings (kEditorKindMapId)
  92. {
  93.     kODEditorKinds,
  94.     {
  95.         kYourPartEditor, 
  96.         kODIsAnISOStringList 
  97.         {
  98.             {
  99.                 kYourPartKind,
  100.                 kSurfPartKind
  101.             }
  102.         }
  103.     }
  104. }
  105.  
  106. In this example, you would need to change the kYourPartKind string to match your part's data format. Do not change the kYourPartEditor string since PartMaker sets this information correctly when you generate the part.
  107.  
  108. If your part supports multiple data formats, make sure that you list the formats in order of fidelity, starting with your part's native format.
  109.  
  110. Editor User String
  111. The Editor User String resource allows OpenDoc to map an instance of your part to a user-readable text string. 
  112.  
  113. resource kODNameMappings (kEditorUserStringMapId)
  114. {
  115.     kODEditorUserString,
  116.     {
  117.         kYourPartEditor, 
  118.         kODIsINTLText 
  119.         { 
  120.             smRoman,
  121.             langEnglish,
  122.             kEditorUserString
  123.         }
  124.     }
  125. }
  126.  
  127. In this example, you would need to change the text of the kEditorUserString to identify your part. This text could contain something like "My Part 1.0".
  128.  
  129. Kind User String
  130. The Kind User String resource allows OpenDoc to map the kinds of data supported by your part to user-readable strings. 
  131.  
  132. resource kODNameMappings (kEditorUserStringMapId)
  133. {
  134.     kODKindUserString,
  135.     {
  136.         kYourPartKind, 
  137.         kODIsINTLText 
  138.         { 
  139.             smRoman,
  140.             langEnglish,
  141.             kYourKindUserString
  142.         }
  143.     }
  144. }
  145.  
  146. In this example, you would need to change the text of the kYourKindUserString to identify your data. This text would contain something like "My Part data". If you hadn't changed the kYourPartKind string already, you would also need to do that.
  147.  
  148. Category User String
  149. The Category User String resource allows OpenDoc to map the categories supported by your part to user-readable strings. You do not have to specify this resource if your part uses only OpenDoc standard categories.
  150.  
  151. resource kODNameMappings (kEditorUserStringMapId)
  152. {
  153.     kODKindUserString,
  154.     {
  155.         kYourNewCategory, 
  156.         kODIsINTLText 
  157.         { 
  158.             smRoman,
  159.             langEnglish,
  160.             kYourCategoryUserString
  161.         }
  162.     }
  163. }
  164.  
  165. In this example, you would need to change the text of the kYourNewCategory and kYourCategoryUserString since they are specific to your part. You do not need to specify a text string for the kODCategoryDrawing category, since OpenDoc defines this string already.
  166.  
  167. Mac OS Type mapping
  168. The Mac OS Type mapping allows OpenDoc to map the data formats supported by your part to Mac OS types. The basic format of this resource looks like the following:
  169.  
  170. resource kODNameMappings (kEditorKindMapId)
  171. {
  172.     kODKindOldMacOSType,
  173.     {
  174.         kYourPartKind, 
  175.         kODIsMacOSType 
  176.         {
  177.             kYourPartMacOSType
  178.         },
  179.  
  180.         kSurfPartKind, 
  181.         kODIsMacOSType 
  182.         {
  183.             kSurfPartMacOSType
  184.         },
  185.     }
  186. }
  187.  
  188. In this example, you would need to change the kYourPartMacOSType to match your part's Mac OS type. If you hadn't changed the kYourPartKind string already, you would also need to do that. 
  189.  
  190.  
  191. Platform Type mapping
  192. In addition to OpenDoc part types, your part can support types such as 'TEXT' and 'PICT', used by existing applications. To do this, you must create a new 'nmap' resource of the type kODEditorPlatformKind. In this resource, specify the OSType's that your part supports. (You must also specify a user string and category for these types in your resource.) The following example shows how you would support both 'TEXT' and 'PICT' resources.
  193.  
  194. resource kODNameMappings (kEditorPlatformKinds)
  195. {
  196.     kODEditorPlatformKind,
  197.     {
  198.         kYourPartEditor,
  199.         kODIsPltfmTypeSpac
  200.         {
  201.             {
  202.                 /* First type */ 
  203.                 kODPlatformFileType, 
  204.                 kTEXTOSType,
  205.                 smRoman,
  206.                 langEnglish,
  207.                 kDragKindUserString1,
  208.                 kODCategoryPlainText,
  209.  
  210.                 /* Second type */
  211.                 kODPlatformFileType, 
  212.                 kPICTOSType,
  213.                 smRoman,
  214.                 langEnglish,
  215.                 kDragKindUserString2,
  216.                 kODCategoryDrawing
  217.             }
  218.         }
  219.     }
  220. }
  221.  
  222.  
  223. Changing Your Part Signature
  224.  
  225. You must define a unique signature that distinguishes your part from other parts. This signature is a four-byte code and is analagous to an application creator type. You specify this signature in your part's 'BNDL' resource and to your development environment when you are building your part. See the documentation that comes with your development environment for setting this signature.
  226.  
  227.  
  228. Changing Your Part Icons
  229.  
  230. There are two places where you need to identify your part's icons: your 'BNDL' resource and your Part Info resource. You can modify your 'BNDL' resource in the same way you would for an application. Your Part Info resource is an ODF custom resource that identifies the icon family that OpenDoc uses to display your part as either a large or small icon within a document. 
  231.  
  232. The Part Info resource contains three pieces of information and looks like the following:
  233.  
  234. resource FW_RPartInfo(kPartInfoID)
  235. {
  236.     // ----- Icon ID
  237.     kViewAsIconID,
  238.     
  239.     // ----- Part Name
  240.     kEditorUserString,
  241.     
  242.     // ----- PartKind
  243.     kYourPartKind
  244. };
  245.  
  246. See the document "PartInfo Resource" for more information.
  247.  
  248.  
  249. © 1993 - 1996 Apple Computer, Inc. All rights reserved.
  250. Apple, the Apple Logo, Macintosh, and OpenDoc are trademarks of Apple Computer, Inc., registered in the United States and other countries.